'use strict';

const db = uniCloud.database();
const collection = db.collection('blogs');
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const {
		content,
		images,
		userId,
		userName
	} = event;

	const res = await collection.add({
		blogContent: content,
		images,
		userId,
		userName,
		likeCount: 0
	});
	return {
		code: 0,
		data: res.data,
		message: 'success'
	};

};